home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SYN.ZIP / ND.ASM < prev    next >
Assembly Source File  |  1994-04-16  |  10KB  |  449 lines

  1.         ;---------------------------------------------------------------------
  2.         ; Dot tunnel
  3.         ; -FT/SF
  4.         .model small
  5. code segment para public
  6.         assume cs:code,ds:code
  7.         .386p
  8.         ;
  9.         ; This will compile as a .COM too
  10.         ;
  11.         org 100h
  12. start:  jmp start1
  13.         ;
  14.         ;
  15.         ; Uncomment this for 400 line mode
  16. VGA400  equ 1
  17.         ; Uncomment this for line-algo correction
  18. LINEADJ equ 1
  19.         ;
  20.         ; Define the rotational centers
  21.         ;
  22. ifdef VGA400
  23. Y_CENTER equ 90
  24. X_CENTER equ 100
  25. else
  26. Y_CENTER equ 45
  27. X_CENTER equ 100
  28. endif
  29.  
  30. sin_inc equ 11          ;23
  31. cos_inc equ  9          ;19
  32.  
  33. include sc256.dat
  34. include w1.asm
  35. include circles.asm
  36.  
  37. ;democount       dd      0
  38. draw_page_offs  dw      0A000h
  39. disp_page_offs  dw      0000h
  40.  
  41. ;dpx             dw      180,170,160,150,140,130,120
  42. dotpos_x        dw      numtunnels dup(920)
  43.                 dw      920
  44. dotpos_y        dw      numtunnels dup(0)
  45.                 dw      0
  46. split_scan      dw      12Ch
  47.  
  48. dotcolor label word
  49.         dw       1, 2, 3, 4, 5, 6, 7, 8, 9,10
  50.         dw      11,12,13,14,15,16,17,18,19,20
  51.         dw      21,22,23,24,25,26,27,28,29,30
  52.         dw      31,32,33,34,35,36,37,38,39,40
  53.         dw      41,42,43,44,45,46,47,48,49,50
  54.         dw      51
  55.  
  56.  
  57. dot_frac_x      db      numtunnels dup(0)
  58.                 db      0
  59. dot_frac_y      db      numtunnels dup(0)
  60.                 db      0
  61.  
  62. dot_inc_x       dw      numtunnels dup(0)
  63.                 db      0
  64. dot_inc_y       dw      numtunnels dup(0)
  65.                 db      0
  66.  
  67. dothome_x       dw      0
  68. dothome_y       dw      0
  69.  
  70. currtun dw      0
  71. curr_x  dw      0
  72. curr_y  dw      0
  73. curr_color dw   0
  74.         ;
  75. @swap_pages macro
  76.         mov ax,[draw_page_offs]
  77.         mov [disp_page_offs],ax
  78.         mov bx,0C000h
  79.         sub bx,ax
  80.         mov [draw_page_offs],bx
  81. endm @swap_pages
  82.  
  83. wait_vrt:                               ;
  84.         mov     dx,3dah                 ;
  85. wvr02:  in      al,dx                   ;
  86.         test    al,8                    ;
  87.         jz      wvr02                   ;
  88. wvr01:  in      al,dx                   ;
  89.         test    al,8                    ;
  90.         jnz     wvr01                   ;
  91.         ret                             ;
  92.  
  93.         ; Plot a point, Mode X
  94.         ; CX = page number
  95.         ; DI = planar address in page
  96.         ; AL = color to plot
  97. @plot_one macro
  98.         mov ah,1
  99.         shl ah,cl
  100.         mov al,02
  101.         mov dx,03C4h
  102.         out dx,ax
  103.         add di,[draw_page_offs]
  104.         mov byte ptr es:[di],bl
  105. endm @plot_one
  106.  
  107.         ;
  108.         ;
  109.         ;
  110. plotatunnel proc
  111.         push cx
  112.         push bx
  113.         mov ax,cs:[currtun]
  114.         add ax,ax
  115.         mov si,offset dotoffs
  116.         add si,ax
  117.         mov si,word ptr ds:[si]
  118.         mov bp,dots_per_tunnel
  119.         mov dx,03C4h
  120. pt_05:  ;push cx
  121.         mov bx,word ptr ds:[si]
  122.         mov ax,word ptr ds:[si+2]
  123.         add si,4
  124. ifndef VGA400
  125.         sar ax,1
  126. endif
  127.         add bx,[curr_x]
  128.         add ax,[curr_y]
  129.         ; compare bx to see if its onscreen
  130.         cmp bx,0
  131.         jl pt_nopoint
  132.         cmp bx,315
  133.         jg pt_nopoint
  134.         cmp ax,0
  135.         jl pt_nopoint
  136. ifdef VGA400
  137.         cmp ax,299
  138. else
  139.         cmp ax,149
  140. endif
  141.         jg pt_nopoint
  142.         mov di,ax
  143.         sal di,4
  144.         sal ax,6
  145.         add di,ax
  146.         mov cl,bl
  147.         and cl,3
  148.         sar bx,2
  149.         add di,bx
  150.         mov ah,1
  151.         shl ah,cl
  152.         mov al,02
  153.         out dx,ax
  154.         add di,[draw_page_offs]
  155.         mov bx,[curr_color]
  156.         mov byte ptr es:[di],bl
  157. pt_nopoint:
  158.         dec bp
  159.         jnz pt_05
  160.         pop bx
  161.         pop cx
  162.         ret
  163. plotatunnel endp
  164.  
  165. turn_em_on proc
  166.         mov cx,numtunnels
  167.         mov bx,cx
  168.         add bx,cx
  169.         sub bx,2
  170. ton01:  mov ax,word ptr ds:dotpos_x[bx]
  171.         mov [curr_x],ax
  172.         mov ax,word ptr ds:dotpos_y[bx]
  173.         mov [curr_y],ax
  174.         mov ax,word ptr ds:dotcolor[bx]
  175.         mov [curr_color],ax
  176.         mov ax,cx
  177.         dec ax
  178.         mov [currtun],ax
  179.         call plotatunnel
  180.         sub bx,2
  181.         loop ton01
  182.         ret
  183. turn_em_on endp
  184.  
  185. turn_em_off proc
  186.         mov dx,03C4h
  187.         mov ax,0F02h
  188.         out dx,ax
  189. ifdef VGA400
  190.         mov cx,1800h;1A68h
  191. else
  192.         mov cx,0C00h
  193. endif
  194.         xor eax,eax
  195.         mov di,[draw_page_offs]
  196.         rep stosd
  197.         ret
  198. turn_em_off endp
  199.  
  200. move_the_tunnel proc
  201.         mov cx,numtunnels
  202.         dec cx
  203.         mov bx,cx
  204.         add bx,bx
  205. mt01:   mov ax,word ptr dotpos_x[bx-2]          ; More inward dot (x)
  206.         sub ax,word ptr dotstep[bx]             ; Add the dot step
  207.         ;----
  208. ifdef LINEADJ
  209.         movsx edx,word ptr dot_inc_x[bx]
  210.         movsx eax,ax
  211.         sal eax,8
  212.         push bx
  213.         sar bx,1
  214.         mov al,byte ptr dot_frac_x[bx-1]
  215.         add eax,edx
  216.         mov byte ptr dot_frac_x[bx],al
  217.         pop bx
  218.         sar eax,8
  219. endif
  220.         ;----
  221.         mov word ptr dotpos_x[bx],ax            ; store outward
  222.  
  223.         mov ax,word ptr dotpos_y[bx-2]          ; More inward dot (y)
  224.         mov dx,word ptr dotstep[bx]             ; add dot step /2
  225. ifndef VGA400
  226.         sar dx,1                                ;
  227. endif
  228.         sub ax,dx                               ;
  229.         ;----
  230. ifdef LINEADJ
  231.         movsx eax,ax
  232.         sal eax,8
  233.         push bx
  234.         sar bx,1
  235.         mov al,byte ptr dot_frac_y[bx-1]
  236.         pop bx
  237.         movsx edx,word ptr dot_inc_y[bx]
  238.         add eax,edx
  239.         push bx
  240.         sar bx,1
  241.         mov byte ptr dot_frac_y[bx],al
  242.         pop bx
  243.         sar eax,8
  244. endif
  245.         ;----
  246.         mov word ptr dotpos_y[bx],ax            ; store outward
  247.  
  248.         mov ax,word ptr dot_inc_x[bx-2]
  249.         mov word ptr dot_inc_x[bx],ax
  250.         mov ax,word ptr dot_inc_y[bx-2]
  251.         mov word ptr dot_inc_y[bx],ax
  252.  
  253.         sub bx,2                                ;
  254.         dec cx
  255.         je mtrd
  256.         jmp mt01
  257.         ;-------
  258. mtrd:   mov bx,[dothome_x]
  259.         add bx,sin_inc
  260.         cmp bx,1024
  261.         jl mt02
  262.         sub bx,1024
  263. mt02:   mov [dothome_x],bx
  264.         movsx ax,byte ptr sin256[bx]
  265.         add ax,X_CENTER
  266.         mov [dotpos_x],ax
  267.         ;--
  268. ifdef LINEADJ
  269.         mov bx,X_CENTER
  270.         sub bx,ax
  271.         movsx eax,bx
  272.         sal eax,8
  273.         or eax,eax
  274.         jl @@01
  275.         xor edx,edx
  276.         jmp short @@02
  277. @@01:   mov edx,-1
  278. @@02:   mov ecx,numtunnels
  279.         idiv ecx
  280.         mov [dot_inc_x],ax
  281. endif
  282.         ;-------
  283.         mov bx,[dothome_y]
  284.         add bx,cos_inc
  285.         cmp bx,1024
  286.         jl mt03
  287.         sub bx,1024
  288. mt03:   mov [dothome_y],bx
  289.         movsx ax,byte ptr cos256[bx]
  290. ifndef VGA400
  291.         sar ax,1
  292. endif
  293.         add ax,Y_CENTER
  294.         mov [dotpos_y],ax
  295.         ;--
  296. ifdef LINEADJ
  297.         mov bx,Y_CENTER
  298.         sub bx,ax
  299.         movsx eax,bx
  300.         sal eax,8
  301.         or eax,eax
  302.         jl @@03
  303.         xor edx,edx
  304.         jmp short @@04
  305. @@03:   mov edx,-1
  306. @@04:   mov ecx,numtunnels
  307.         idiv ecx
  308.         mov [dot_inc_y],ax
  309. endif
  310.         ;--------
  311.         mov cx,numtunnels
  312. mt04:   mov bx,numtunnels
  313.         sub bx,cx
  314.         inc bx
  315.         mov eax,[democount]
  316.         and eax,7
  317.         mov dx,bx
  318.         sub dx,ax
  319.         xor ax,ax
  320.         and dx,4
  321.         je mt04b
  322.         ;-----
  323.         mov dx,03C8h
  324.         mov al,bl
  325.         out dx,al
  326.         inc dx
  327.         sal ax,2
  328.         cmp ax,64
  329.         jl mt05a
  330.         mov al,63
  331. mt05a:  out dx,al
  332.         out dx,al
  333.         out dx,al
  334.         jmp short mt04c
  335. mt04b:  mov dx,03C8h
  336.         mov al,bl
  337.         out dx,al
  338.         inc dx
  339.         sal ax,1
  340.         cmp ax,32
  341.         jl mt05b
  342.         mov ax,31
  343. mt05b:  out dx,al
  344.         out dx,al
  345.         out dx,al
  346. mt04c:  loop mt04
  347.         mov [dot_frac_x],0
  348.         mov [dot_frac_y],0
  349.         ret
  350. move_the_tunnel endp
  351.  
  352. start1:
  353.         mov ax,cs
  354.         mov ds,ax
  355.         mov ax,0013h
  356.         int 10h
  357.         mov ax,0A000h
  358.         mov es,ax
  359.         ;-----
  360.         ; unchain the video mode
  361.         mov dx,03C4h
  362.         mov ax,0604h
  363.         out dx,ax
  364.         mov ax,0E317h
  365.         mov dx,03D4h
  366.         out dx,ax
  367.         mov ax,0014h
  368.         out dx,ax
  369.         ;---------
  370.         mov al,09h
  371.         out dx,al
  372.         inc dx
  373.         in al,dx
  374.         and al,010100001b
  375. ifdef VGA400
  376.         and al,0FEh     ; for 400-line mode
  377. endif
  378.         mov ah,al
  379.         mov al,09h
  380.         dec dx
  381.         out dx,ax
  382.  
  383.         mov dx,03D4h
  384.         mov al,07h
  385.         out dx,al
  386.         inc dx
  387.         in al,dx
  388.         mov ah,al
  389.         mov bx,[split_scan]
  390.         and bx,100h
  391.         jz @@06
  392.         or ah,10h
  393.         jmp short @@07
  394. @@06:   and ah,0EFh
  395. @@07:   mov al,07h
  396.         dec dx
  397.         out dx,ax
  398.         mov al,18h
  399.         mov ah,byte ptr ds:[split_scan]
  400.         out dx,ax
  401.  
  402.         mov dx,03C4h
  403.         mov ax,0F02h
  404.         out dx,ax
  405.         mov cx,04000h
  406.         xor eax,eax
  407.         xor di,di
  408.         rep stosd
  409.  
  410.         mov [draw_page_offs],0h
  411.         mov [disp_page_offs],0h
  412.  
  413.         call writer_init
  414.         mov [disp_page_offs],02000h
  415.         mov [draw_page_offs],0A000h
  416.  
  417. cont:
  418.         ; Set the video page
  419.         mov dx,03D4h
  420.         mov bx,[disp_page_offs]
  421.         mov ah,bh
  422.         mov al,0Ch
  423.         out dx,ax
  424.         mov ah,bl
  425.         mov al,0Dh
  426.         out dx,ax
  427.  
  428.         call wait_vrt
  429.         call move_the_tunnel
  430.         call turn_em_off
  431.         call turn_em_on
  432.         call do_writing
  433.  
  434.         @swap_pages
  435.         inc [democount]
  436.         mov ah,01
  437.         int 16h
  438.         jz cont
  439.  
  440. exit:
  441.         mov ax,0003h
  442.         int 10h
  443.         mov ax,4C00h
  444.         int 21h
  445.  
  446. code ends
  447.         end start
  448.  
  449.